package csdn;

import java.io.FileReader;
import java.io.IOException;

public class Test7 {
    public static void main(String[] args) {
        String path="D:\\javacode\\javacode\\IO_1\\read.txt";
        FileReader fileReader=null;
        int readlen=0;
        char []buf=new char[8];
        try {
            fileReader = new FileReader(path);
            while((readlen=fileReader.read(buf))!=-1){
                System.out.print(new String(buf,0,readlen));
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }finally {
            //关闭字符流，释放资源
            try {
                fileReader.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
